package io.renren.controller;

import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.entity.SocialSecurityPayDetailEntity;
import io.renren.service.SocialSecurityPayDetailService;
import io.renren.utils.PageUtils;
import io.renren.utils.Query;
import io.renren.utils.R;


/**
 * 社保缴付明细
 * 
 * @author zhangheng
 * @email zh_123shmily@163.com
 * @date 2017-07-09 19:04:52
 */
@RestController
@RequestMapping("socialsecuritypaydetail")
public class SocialSecurityPayDetailController {
	@Autowired
	private SocialSecurityPayDetailService socialSecurityPayDetailService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("socialsecuritypaydetail:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<SocialSecurityPayDetailEntity> socialSecurityPayDetailList = socialSecurityPayDetailService.queryList(query);
		int total = socialSecurityPayDetailService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(socialSecurityPayDetailList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("socialsecuritypaydetail:info")
	public R info(@PathVariable("id") Integer id){
		SocialSecurityPayDetailEntity socialSecurityPayDetail = socialSecurityPayDetailService.queryObject(id);
		
		return R.ok().put("socialSecurityPayDetail", socialSecurityPayDetail);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("socialsecuritypaydetail:save")
	public R save(@RequestBody SocialSecurityPayDetailEntity socialSecurityPayDetail){
		socialSecurityPayDetailService.save(socialSecurityPayDetail);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("socialsecuritypaydetail:update")
	public R update(@RequestBody SocialSecurityPayDetailEntity socialSecurityPayDetail){
		socialSecurityPayDetailService.update(socialSecurityPayDetail);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("socialsecuritypaydetail:delete")
	public R delete(@RequestBody Integer[] ids){
		socialSecurityPayDetailService.deleteBatch(ids);
		
		return R.ok();
	}

	/**
	 * 删除
	 */
	@RequestMapping("/getInOutList")
	@RequiresPermissions("socialsecuritypaydetail:list")
	public R getInOutList(@RequestBody JSONObject jsonObject){
		socialSecurityPayDetailService.getInOutList(jsonObject);
		return R.ok();
	}
	
}
